import { createRouter, createWebHistory } from 'vue-router';
import { setupLayouts } from 'virtual:generated-layouts';
import generatedRoutes from 'virtual:generated-pages';
import RouterTutorial from '../pages/router-tutorial/index.vue';

const routes = setupLayouts(generatedRoutes);

// 添加自定义路由
routes.push({
  path: '/router-tutorial',
  name: 'RouterTutorial',
  component: RouterTutorial
});

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
});

// 添加全局后置钩子
// router.afterEach((to, from) => {
//   // 打印当前路由对象
//   console.log('当前路由：', to);
//   // 如果需要打印从哪个路由来
//   console.log('从路由：', from);
// });

export default router;
